<?php
session_start();
    include '../../../controlador/php/conexion/Conexion.php';
    $con = new Conexion();
    
    $bentrada = "select COUNT(*)as resp 
                 from dnhistorial as h inner join dnsolicitud as soli on h.dnsolicitud=soli.dnsoid
                 outer apply (select top 1 dnhistorial.usu_oid
                                           from dnhistorial left outer join usuario on dnhistorial.usu_oid = usuario.usu_oid
                                           where dnsolicitud = soli.dnsoid and hisestado = 2
                                           order by usuario.usu_oid desc)as asignado
                 where asignado.usu_oid = ".$_SESSION['usuario']." and dnsestado = 8 and hisestado = 8";
    $res = $con->query($bentrada);
    
    
    while ($respu = mssql_fetch_array($res)){
        $respuesta[] = array_map(utf8_encode,$respu);
    }
    
    $con->cerrarConexion();
    print_r(json_encode($respuesta))
?>
